﻿#region Using namespaces

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Input;

using AvalonDock;

#endregion

namespace BOL.Apps.GeneNetworkBrowser.ViewModels
{
    public sealed class AnnotationPaneViewModel : PaneViewModel
    {
        #region Private variables

        private ObservableCollection<Gene> _genes; 

        #endregion

        #region Public properties

        public ObservableCollection<Gene> Genes
        {
            get { return _genes; }
            set
            {
                if (value != _genes)
                {
                    _genes = value;
                    OnPropertyChanged("Genes");
                }
            }
        }

        #endregion

        #region Constructor

        public AnnotationPaneViewModel(MainWindowViewModel vmMainWindow)
            : base(vmMainWindow)
        {
            if (_vmMainWindow == null)
                throw new ArgumentNullException();
            
            _vmMainWindow.ActiveDocumentChanged += new EventHandler<EventArgs>(MainWindowViewModel_ActiveDocumentChanged);
        }

        private void MainWindowViewModel_ActiveDocumentChanged(object sender, EventArgs e)
        {
            if (_vmMainWindow.ActiveDocument is NetworkDocumentViewModel)
            {
                var vmNetworkDocument = _vmMainWindow.ActiveDocument as NetworkDocumentViewModel;
                Genes = new ObservableCollection<Gene>(vmNetworkDocument.Network.Vertices);
            }
        }

        #endregion
    }
}
